package serverSide;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wb.swt.SWTResourceManager;

public class Login extends Shell {
	private Text txtPassword;
	private Text txtUserName;
	String result = null;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String args[]) {
		try {
			Display display = Display.getDefault();
			Login shell = new Login(display);
			shell.open();
			shell.layout();
			while (!shell.isDisposed()) {
				if (!display.readAndDispatch()) {
					display.sleep();
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the shell.
	 * @param display
	 */
	public Login(Display display) {
		super(display, SWT.CLOSE | SWT.TITLE);
		setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY));
		setLayout(new FormLayout());
		
		Composite composite = new Composite(this, SWT.NONE);
		composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY));
		FormData fd_composite = new FormData();
		fd_composite.bottom = new FormAttachment(0, 128);
		fd_composite.right = new FormAttachment(0, 388);
		fd_composite.top = new FormAttachment(0);
		fd_composite.left = new FormAttachment(0);
		composite.setLayoutData(fd_composite);
		composite.setLayout(new FormLayout());
		
		Label lblUsername = new Label(composite, SWT.NONE);
		FormData fd_lblUsername = new FormData();
		fd_lblUsername.top = new FormAttachment(0, 20);
		lblUsername.setLayoutData(fd_lblUsername);
		lblUsername.setText("UserName:");
		
		Label lblPassword = new Label(composite, SWT.NONE);
		fd_lblUsername.left = new FormAttachment(lblPassword, 0, SWT.LEFT);
		FormData fd_lblPassword = new FormData();
		fd_lblPassword.left = new FormAttachment(0, 27);
		fd_lblPassword.top = new FormAttachment(lblUsername, 28);
		lblPassword.setLayoutData(fd_lblPassword);
		lblPassword.setText("Password:");
		
		txtPassword = new Text(composite, SWT.BORDER);
		txtPassword.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
		FormData fd_txtPassword = new FormData();
		txtPassword.setLayoutData(fd_txtPassword);
		
		txtUserName = new Text(composite, SWT.BORDER);
		txtUserName.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
		fd_txtPassword.right = new FormAttachment(txtUserName, 0, SWT.RIGHT);
		fd_txtPassword.top = new FormAttachment(txtUserName, 19);
		fd_txtPassword.left = new FormAttachment(txtUserName, 0, SWT.LEFT);
		FormData fd_txtUserName = new FormData();
		fd_txtUserName.bottom = new FormAttachment(100, -87);
		fd_txtUserName.right = new FormAttachment(100, -49);
		fd_txtUserName.left = new FormAttachment(lblUsername, 6);
		txtUserName.setLayoutData(fd_txtUserName);
		
		Button btnLogin = new Button(composite, SWT.NONE);
		btnLogin.setToolTipText("Click to login");
		btnLogin.setSelection(true);
		btnLogin.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				
			}
		});
		FormData fd_btnLogin = new FormData();
		fd_btnLogin.bottom = new FormAttachment(100, -10);
		btnLogin.setLayoutData(fd_btnLogin);
		btnLogin.setText("Login");
		
		Button btnCancel = new Button(composite, SWT.NONE);
		btnCancel.setToolTipText("Click to close");
		btnCancel.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
			}
		});
		fd_btnLogin.left = new FormAttachment(btnCancel, -115, SWT.LEFT);
		fd_btnLogin.right = new FormAttachment(btnCancel, -25);
		FormData fd_btnCancel = new FormData();
		fd_btnCancel.right = new FormAttachment(100, -65);
		fd_btnCancel.left = new FormAttachment(0, 244);
		fd_btnCancel.bottom = new FormAttachment(100, -10);
		btnCancel.setLayoutData(fd_btnCancel);
		btnCancel.setText("Cancel");
		createContents();
	}

	/**
	 * Create contents of the shell.
	 */
	protected void createContents() {
		setText("SWT Application");
		setSize(404, 167);

	}

	@Override
	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
	}
}
